package me.pearjelly.filters.commons;

import me.pearjelly.filters.VisitFilter;
import edu.uci.ics.crawler4j.url.WebURL;

public class DepthFilter implements VisitFilter {
	private int depth;
	private VisitFilter visitFilter;

	public DepthFilter(int depth, VisitFilter visitFilter) {
		this.depth = depth;
		this.visitFilter = visitFilter;
	}

	@Override
	public boolean filter(WebURL webURL) {
		return webURL.getDepth() <= this.depth
				&& (null == visitFilter || visitFilter.filter(webURL));
	}
}
